﻿define([], function () {
    
    //private variables
    var _kendoApp;

    /*RETURN*/
    return {

        //function: init
        init: function (kendoApp) {
            _kendoApp = kendoApp;
        },

        //function: navigate
        navigate: function (location) {
            _kendoApp.navigate(location);
        },

        //function: redirect
        redirect: function (location) {
            _kendoApp.pane.history.pop();
            _kendoApp.navigate(location);
        },

        //function: scrollViewToTop
        scrollViewToTop: function (viewElement) {
            viewElement.data("kendoMobileView").scroller.reset();
        },
        
        //function: showLoading
        showLoading: function (message) {
            $(".loading-message").text(message ? message : "Loading...");
            _kendoApp.showLoading();
        },
        
        //function: hideLoading
        hideLoading: function () {
            _kendoApp.hideLoading();
        },

        //function: formatToWebAPiJSon
        formatToWebAPiJSon: function (data) {
            //because the WebApi binding does not accept the kendo model, let's strip the [, ] characters.... to make it Json clean
            var finalString = JSON.stringify(data);
            finalString = finalString.replace("[", "")
            finalString = finalString.replace("]", "");
            return finalString;
        }
    }   // --> end Return
});